05. Set up a bookkeeping database
PRDTM2-787 AI Trading C4 L3 Vid5 Set Up A Bookkeeping Database
Setting Up a Bookkeeping Database for Trading
Using an SQLite3 database is crucial for tracking trading operations. The setup works like this:
Database Connection
- Connect to SP500.db: Use this database file for local storage.
Structuring the Database
- Function: Prepare: Collect relevant code for database preparation.
Positions Table
- Purpose: Track position changes after each trade.
- Columns:
- Time of Trade: Text field for recording trade time.
- Instrument: Name of the trading instrument, e.g.,
APEL.Ofor Apple orSPX 500for S&P 500. - Quantity: Number of units held after trade. Positive for buy, negative for sell.
- Cash: Available cash post-trade.
Table Features
- Primary Key: Combination of
Time of TradeandInstrumentto prevent duplicate entries. - Efficiency: Primary key specification speeds up queries.
Stay tuned for coding the momentum strategy using geometric Brownian motion.